/*
  将下面异步代码使用 Promise 的方法改进
  尽量用看上去像同步代码的方式
  setTimeout(function () {
    var a = 'hello'
    setTimeout(function () {
      var b = 'lagou'
      setTimeout(function () {
        var c = 'I ♥ U'
        console.log(a + b +c)
      }, 10)
    }, 10)
  }, 10)
*/

const timeOut = (callback) => {
  return new Promise((resove, reject) => {
    setTimeout(async () => {
      resove(callback);
    }, 10);
  });
};

async function hello() {
  const _hello = await timeOut(() => {
    const a = "hello";
    return a;
  });
  return _hello();
}
async function lagou() {
  const _lagou = await timeOut(() => {
    const b = "lagou";
    return b;
  });
  return _lagou();
}
async function ilove() {
  const _ilove = await timeOut(() => {
    const c = "I ♥ U";
    return c;
  });
  return _ilove();
}

async function allFn() {
  let a = await hello();
  let b = await lagou();
  let c = await ilove();
  console.log(a + b +c)
}
allFn();
